<style>
    .layui-form-label{
        width: 120px!important;
    }
</style>
<div style="margin: 5% 5%;">
  <form class="layui-form" action="" lay-filter="example">

    <div class="layui-form-item ">
      <div class="layui-inline">
        <label class="layui-form-label">分组名称:</label>
        <div class="layui-input-inline">
          <input type="text"  name="groupName" autocomplete="off" class="layui-input" value="">
        </div>
      </div>
    </div>

    <div class="layui-form-item ">
      <div class="layui-inline">
        <label class="layui-form-label">分组状态:</label>
        <div class="layui-input-inline">
          <select name="groupStatus" >
            <option value="启用" >启用</option>
            <option value="禁用" >禁用</option>
          </select>
        </div>
      </div>
    </div>

    <div class="layui-form-item " style="display: none;">
      <div class="layui-inline">
        <div class="layui-input-inline">
          <input type="text" name="groupStationId" class="layui-input" value="">
        </div>
      </div>
    </div>

    <div class="layui-form-item">
      <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">新增</button>
      </div>
    </div>

  </form>
</div>
<script src="/js/layui/layui.all.js"></script>
<script src="/admin/js/token.js"></script>
<script>

  var local_store = layui.data("local_store");
  var local = local_store.token;
  var $ = layui.$;
  $.ajax({
    type:"get",
    url:"/admin/station/query/stationLoginQuanxXian?stationId="+json.id,
    dataType: "json",
    contentType:"application/json;charset=utf-8",
    beforeSend: function(request) {
      request.setRequestHeader("token", local);
    },
    success:function (res) {
      if (res.code == 500) {
        alert("权限不足")
        location = "../../admin/main.html";
        return
      }
    }
  })

    var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

    form.on('submit(demo1)',function (data) {

      $.ajax({
        url: "/admin/group/add/group",
        type: 'POST',
        dataType: "JSON",
        contentType:"application/json;charset=utf-8",
        data:JSON.stringify(data.field),
        // beforeSend: function () {
        //   this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
        // },
        success: function (res) {
          if (res.code == 500) {
            layer.msg("新增失败\t"+res.data, {icon: 5,time: 1000});//失败的表情
            return;
          } else if (res.code == 200) {
            layer.msg("新增成功", {
              icon: 6,//成功的表情
              time: 1000 //1秒关闭（如果不配置，默认是3秒）
            }, function () {
              location.reload();
            });
          }
        },
        complete: function () {
          layer.close(this.layerIndex);
        },
      });
      return false;//阻止表单跳转
    });

  function GetRequest() {
    var url = decodeURI(location.search); //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
      var str = url.substr(1);
      strs = str.split("&");
      for(var i = 0; i < strs.length; i ++) {
        theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
      }
    }
    return theRequest;
  }

  var json=GetRequest();
  $("input[name='groupStationId']").attr("value",json.id)

</script>